<% layout('/layouts/default.html', {title: '任务部署信息表(主)管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<#form:form id="searchForm" model="${dcSupTaskInfo}" action="${ctx}/taskdeploy/dcSupTaskInfoRefine/queryRefineListData" method="post" class="form-inline"
				data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div style="float: right">
				<div class="form-group">
					<label class="control-label">${text('任务年度')}：</label>
					<div class="control-inline width-120">
						<#form:select path="taskYear" items="${yearList}" blankOption="true" data-placeholder="请选择" itemLabel="yearLabel" itemValue="yearValue" class="form-control width-120" defaultValue="${currentYear}"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务标题')}：</label>
					<div class="control-inline width-160">
						<#form:input path="taskTitle" maxlength="200" class="form-control width-160" placeholder="请输入任务标题"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务类型')}：</label>
					<div class="control-inline width-160">
						<#form:select path="taskTypeCode" items="${dicts}" blankOption="true" data-placeholder="请选择" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-160"/>
					</div>
				</div>
				<div class="form-group" >
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</div>
		</#form:form>
	</div>
	<div class="box-body">
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
	</div>
</div>
</div>
<% } %>
<script>
	//重置
	function cz(){
		searchForm.reset();
		$('#dataGrid').dataGrid('reloadGrid');
	}

	// 初始化DataGrid对象
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		sortableColumn: false, // 列表不允许排序
		columnModel: [
			{header:'${text("主键")}', name:'id', index:'a.id', width:150, align:"left", hidden:true},
			{header:'${text("任务主键")}', name:'taskId', index:'a.task_id', width:200, align:"left", hidden:true},
			{header:'${text("督办字号")}', name:'dcSupTaskInfo.messageNumber', index:'a.message_number', width:100, align:"left"},
			{header:'${text("任务标题")}', name:'dcSupTaskInfo.taskTitle', index:'a.task_title', width:150, align:"left"},
			{header:'${text("任务类型")}', name:'dcSupTaskInfo.taskTypeName', index:'a.task_type_name', width:150, align:"left"},
			{header:'${text("任务内容")}', name:'dcSupTaskInfo.taskContent', index:'a.task_content', width:150, align:"left", formatter: function(val, obj, row, act){
					return '<a href="${ctx}/taskdeploy/dcSupTaskInfo/detailForm?id='+row.dcSupTaskInfo.id+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无内容')+'</a>';
				}},
			/*{header:'${text("牵头领导")}', name:'dcSupTaskInfo.taskLeaderName', index:'a.task_leader_name', width:150, align:"left"},*/
			{header:'${text("牵头责任单位")}', name:'taskLeaderOrgName', index:'a.task_leader_org_name', width:150, align:"left"},
			{header:'${text("负责人")}', name:'transferName', index:'a.transfer_name', width:100, align:"left"},
			{header:'${text("审核状态")}', name:'auditStatus', index:'a.audit_status', width:100, align:"left",formatter: function(val, obj, row, act){
					if (val == '0') {
						return '未审核';
					} else if (val == '1') {
						return '审核通过';
					} else if (val == '2') {
						return '审核驳回';
					} else {
						return '未分解';
					}
				}},
			{header:'${text("驳回意见")}', name:'auditOption', width:100, align:"left"},
			{header:'${text("操作")}', name:'dcSupTaskInfo.actions', width:160, align:"center",formatter: function(val, obj, row, act){
					var actions = [];
					if(row.auditStatus != '0' && row.auditStatus != "1"){
						actions.push('<a href="#" class="btn btn-primary btn-xs " onclick=refineForm("'+row.id+'") title="${text("细化分解")}">细化分解</a>&nbsp;&emsp;');
						actions.push('<a href="#" class="btn btn-primary btn-xs " onclick=transfer("'+row.id+'") title="${text("工作安排")}">工作安排</a>&nbsp;&emsp;');
					} else {
						actions.push('<a href="#" class="btn btn-primary btn-xs " onclick=refineForm("'+row.id+'") title="${text("查看分解")}">查看分解</a>&nbsp;&emsp;');
					}

					return actions.join('');
				}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});

	// 细化分解
	function refineForm(id) {
		js.addTabPage(null, "细化分解任务确认","${ctx}/taskdeploy/dcSupTaskInfoRefine/refineForm?id="+id , true);
	}
	// 工作安排
	function transfer(id){
		js.layer.open({
			type: 2,
			title: ['工作安排'],
			area: ['800px', '200px'],
			scrollbar: true,
			shadeClose: false,
			content: "${ctx}/taskdeploy/dcSupTaskInfoRefine/transfer?id="+id,
			btn1: function (index, layero) {
			},
			end:function () {
				$('#dataGrid').dataGrid('refresh', 1, 20);
			}
		});
	}
</script>